<?php $this->load->view('tourism/layout/header') ?>
<header class="am-search">
    <ul class="am-cf">
        <a href="javascript:history.back();">
            <li class="r-black">
                <i class="iconfont icon-zuojiantou"></i>
            </li>
        </a>
        <li class="header-input">
            <p>商品详情</p>
        </li>
        <li class="header-home">
            <?php $this->load->view('tourism/layout/nav'); ?>
        </li>
    </ul>
</header>
<div class="circuittest-first">
    <div class="order-details">
        <div class="am-addressee buyer-pay am-cf">
            <span class="am-icon am-car"><img src="/skins/tourism/images/xq.png"></span>
            <div class="ad-text">
                <?php if($orderInfo->order_state == 1 && $orderInfo->order_status == 1):?>
                    <p>交易已取消</p>
                <?php elseif($orderInfo->order_state == 1 && $orderInfo->order_status == 2):?>
                    <p>等待买家付款</p>
                <?php elseif($orderInfo->order_state == 2 && $orderInfo->order_status == 3):?>
                    <p>买家已付款</p>
                <?php elseif($orderInfo->order_state == 2 && $orderInfo->order_status == 4):?>
                    <p>卖家已发货</p>
                <?php elseif($orderInfo->order_state >= 3 && $orderInfo->order_status >= 5):?>
                    <p>交易成功</p>
                <?php endif; ?>
            </div>
        </div>
        <div class="am-addressee am-cf">
            <span class="iconfont am-icon icon-shouhuodizhi"></span>
            <?php $address = json_decode($orderInfo->detail);?>
            <div class="ad-text">
                <div class="name am-cf">
                    <p>收货人：<span><?php echo $address->receiver_name ?></span></p>
                    <i><?php echo $address->tel ?></i>
                </div>
                <div class="take-goods">收货地址：
                    <span><?php echo $address->detailed ?></span>
                </div>
            </div>
        </div>
        <?php if($orderInfo->order_status == 4 && isset($logisticsInfo) && $logisticsInfo->ischeck >= 0): ?>
        <div class="am-addressee am-cf">
            <a href="<?php echo site_url('tourism/user/tracking/'.$orderInfo->order_id);?>">
                <span class="iconfont am-icon icon-buoumaotubiao39"></span>
                <div class="ad-text text-name">
                    <div class="name am-cf">
                        <p>物流信息</p>
                    </div>
                    <?php $data = json_decode($logisticsInfo->context); ?>
                    <div class="logistics">
                        <p class="mation"><?php if(is_array($data)){echo $data[0]->context;}else{echo '暂无物流信息';}  ?></p>
                    </div>
                </div>
                <span class="ad-check">
                    <i class="iconfont am-icon icon-youjiantou"></i>
                </span>
            </a>
        </div>
        <?php endif ?>
        <?php if (!empty($orderInfo->message)): ?>
        <div class="am-addressee am-cf">
            <span class="iconfont am-icon icon-liuyan"></span>
            <div class="ad-text">
                <div class="name am-cf">
                    <p>买家留言</p>
                </div>
                <div class="logistics">
                    <p class="times"><?php echo $orderInfo->message?></p>
                </div>
            </div>
        </div>
        <?php endif ?>
        <div class="am-title cox am-cf">
            <span class="check-wrapper"></span>
            <i><?php echo $orderInfo->alias_name?></i>
        </div>
        <div class="am-addsee">
            <ul>
                <?php foreach($orderList as $value): ?>
                <li class="details-ie">
                    <div class="details am-cf">
                        <div class="products-img">
                            <a href="<?php echo site_url('tourism/goods/info/'.$value->goods_attr_id);?>">
                                <img class="lazy" src="/skins/tourism/images/load.jpg" data-original="<?php echo $this->config->show_image_url($value->goods_image, '300-300');?>">
                            </a>
                        </div>
                        <div class="am-midd">
                            <a title="<?php echo $value->goods_name?>" href="<?php echo site_url('tourism/goods/info/'.$value->goods_attr_id);?>"><?php echo $value->goods_name?></a>
                            <div class="fyText am-cf">
                                <?php $attribute =explode(',',$value->attribute_value)?>
                                <?php foreach($attribute as $val): ?>
                                    <span><?php echo $val?></span>
                                <?php endforeach ?>
                            </div>
                        </div>
                        <div class="am-pic">
                            <span>￥<?php echo $value->pay_amount?></span>
                            <i class="add">x<?php echo $value->refund_num;?></i>
                            <?php if(empty($value->status) && $orderInfo->order_state == 2 && $orderInfo->order_status >= 3 && $orderInfo->order_status < 6):?>
                                    <a href="<?php echo site_url('tourism/refund/apply/'.$value->order_product_id); ?>" class="am-btn order-refund" >退款</a>
                            <?php elseif($value->status > 0):?>
                                <a href="<?php echo site_url('tourism/refund/details/'.$value->refund_id); ?>" class="am-btn order-refund-detail" >
                                    <?php if($value->status == 1):?>
                                    退款中
                                    <?php elseif($value->status == 2):?>
                                    退款成功
                                    <?php elseif($value->status == 3):?>
                                    退款失败
                                    <?php endif ?>
                                </a>
                            <?php endif; ?>
                        </div>
                    </div>
                </li>
                <?php endforeach ?>
            </ul>
        </div>
        <div class="am-addressee">
             <?php if($orderInfo->pay_swim>0):?>
            <div class="transp am-cf">
                <i>积分：</i>
                <p>￥<span><?php echo $orderInfo->pay_swim; ?></span></p>
            </div>
            <?php endif;?>
            <div class="transp am-cf">
                <i>运费：</i>
                <p>￥<span><?php echo $orderInfo->transport_cost; ?></span></p>
            </div>
            <div class="transp am-cf">
                <i>实付款：</i>
                <p class="pay">￥<span><?php echo bcadd($orderInfo->order_pay_total, $orderInfo->transport_cost, 2) ?></span></p>
            </div>
        </div>
        <div class="am-addressee">
            <p class="order-number">订单号：<span><?php echo $orderInfo->order_sn ?></span></p>
            <?php if ($orderInfo->order_state >= 1 && $orderInfo->order_state >= 2): ?>
            <p class="order-number">创建时间：<span><?php echo $orderInfo->created_at; ?></span></p>
            <!-- 支付成功 -->
            <?php endif ?>
            <?php if($orderInfo->order_state >= 2 && $orderInfo->order_state >= 3): ?>
                <p class="order-number">支付时间：<span><?php echo $orderInfo->pay_time; ?></span></p>
            <?php endif ?>
                <!-- 已发货 -->
            <?php if($orderInfo->order_state >= 2 && $orderInfo->order_state >= 4): ?>
                <p class="order-number">发货时间：<span><?php echo $orderInfo->send_time; ?></span></p>
            <?php endif ?>
                <!-- 到货时间 -->
            <?php if($orderInfo->order_state >= 3 && $orderInfo->order_state >= 5): ?>
                <p class="order-number">成交时间：<span><?php echo $orderInfo->receive_time; ?></span></p>
            <?php endif ?>
        </div>
        <?php if($orderInfo->order_status != 1 && $orderInfo->order_status != 3):?>
        <div class="logistics-shipments" id="logistics-wrapper">
            <?php if($orderInfo->order_state == 1 && $orderInfo->order_status == 2):?>
                <a href="<?php echo site_url('tourism/user/cancelOrder/'.$orderInfo->order_id)?>" class="am-btn">取消订单</a>
                <a href="<?php echo site_url('tourism/usertopay/payOrder/'.$orderInfo->order_sn)?>" class="am-btn">去支付</a>
            <?php endif ?>
            <?php if($orderInfo->order_state == 2 && $orderInfo->order_status == 3):?>
            <?php endif ?>
            <?php if($orderInfo->order_state >= 2 && $orderInfo->order_status >= 4):?>
                <a href="<?php echo site_url('tourism/user/tracking/'.$orderInfo->order_id);?>" class="am-btn">查看物流</a>
            <?php endif ?>
            <?php if($orderInfo->order_state >= 3 && $orderInfo->order_status == 5):?>
                <a href="<?php echo site_url('tourism/tourismevaluate/evaluate/'.$orderInfo->order_id);?>" class="am-btn">评价</a>
            <?php endif; ?>
        </div>
        <?php endif ?>
    </div>
</div>
<?php $this->load->view('tourism/layout/footer') ?>